package com.example.a2;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private TextView tvMainTitle;
    private EditText edTextMainUserName;
    private EditText edtTextMainPassword;
    private Button btnMainLogin;
    private Button btnMainRegister;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }
    @Override
    public void onClick(View v){
        switch (v.getId()){
            case R.id.btn_main_Register:
                if (edTextMainUserName.getText().toString().equals("admin")&
                        edtTextMainPassword.getText().toString().equals("123456"))
                    new AlertDialog.Builder(this)
                            .setTitle("登录信息")
                            .setMessage("登陆成功")
                            .setPositiveButton("",null)
                            .create()
                            .show();
                break;
            case R.id.btn_register_Exit:
                Intent intent = new Intent(MainActivity.this,RegisterActivity.class);
                startActivity(intent);
                break;
        }

    }




    private void initView() {
        tvMainTitle = (TextView) findViewById(R.id.tv_main_title);
        edTextMainUserName = (EditText) findViewById(R.id.edText_main_UserName);
        edtTextMainPassword = (EditText) findViewById(R.id.edtText_main_Password);
        btnMainLogin = (Button) findViewById(R.id.btn_main_Login);
        btnMainRegister = (Button) findViewById(R.id.btn_main_Register);
        btnMainLogin.setOnClickListener(this);
        btnMainRegister.setOnClickListener(this);
    }

}